//package com.rainbow.controller;
//
//import com.alibaba.fastjson.JSON;
//import com.rainbow.domain.Order;
//import com.rainbow.domain.Product;
//import com.rainbow.service.ProductService;
////import com.rainbow.service.impl.OrderServiceImpl4;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//@RestController
//@Slf4j
//public class OrderController4 {
//    @Autowired
//    private OrderServiceImpl4 orderService;
//    @Autowired
//    private ProductService productService;
//    // 下单
//    @RequestMapping("/order/prod/{pid}")
//    public Order order(@PathVariable("pid") Integer pid){
//        log.info("接受到{}号商品下单,下面查询商品信息",pid);
//        Product product = productService.findByPid(pid);
//        if(product==null || product.getPid()==-100){
//            Order order = new Order();
//            order.setOid(-100L);
//            order.setPname("下单失败");
//            return order;
//        }
//        log.info("查询到商品{} : {}",pid, JSON.toJSONString(product));
//
//        // 下单
//        Order order = new Order();
//        order.setUid(1);
//        order.setUsername("测试用户");
//        order.setPid(pid);
//        order.setPname(product.getPname());
//        order.setPprice(product.getPprice());
//        order.setNumber(1);
//
//        orderService.createOrderBefore(order);
//        log.info("创建订单成功, {}",JSON.toJSONString(order));
//        return order;
//    }
//
//}
